package priv.bruce.service;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import priv.bruce.entry.MovieComment;
import priv.bruce.entry.UserInfo;
import priv.bruce.util.HandlerSet;
import priv.bruce.util.JDBCUtil;

public class DeleteCommentService implements HandlerSet<MovieComment>{

	public int deleteComment(int id) throws Exception{
		String sql = "DELETE FROM t_comment WHERE comment_id = ?";
		int changeRows = JDBCUtil.update(sql, id);
		return changeRows;
	}
	
	public List<MovieComment> findCommentById(int id) throws Exception{
		String sql = "SELECT * FROM t_comment WHERE comment_id = ?";
		
		return JDBCUtil.query(sql, this, id);
	}
	
	@Override
	public MovieComment handler(ResultSet rs) throws SQLException {
		MovieComment comment = new MovieComment();
		comment.setComment_id(rs.getInt("comment_id"));
		comment.setUser_id(rs.getInt("user_id"));
		comment.setMovie_id(rs.getInt("movie_id"));
		comment.setComment_content(rs.getString("comment_content"));
		comment.setComment_zan(rs.getInt("comment_zan"));
		return comment;
	}
}
